<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<!--
	main html header
	-->
	<xsl:template name="header">
		
		<!-- title -->
		<title><xsl:value-of select="/root/gui/strings/title"/></title>
		<link href="{/root/gui/url}/favicon.ico" rel="shortcut icon" type="image/x-icon" />
		<link href="{/root/gui/url}/favicon.ico" rel="icon" type="image/x-icon" />

		<!-- stylesheet -->
		<link rel="stylesheet" type="text/css" href="{/root/gui/url}/geonetwork.css"/>
		
		<!-- Recent updates newsfeed -->
		<link href="{/root/gui/locService}/rss.latest?georss=gml" rel="alternate" type="application/rss+xml" title="GeoNetwork opensource GeoRSS | {/root/gui/strings/recentAdditions}" />
		<link href="{/root/gui/locService}/portal.opensearch" rel="search" type="application/opensearchdescription+xml">

		<xsl:attribute name="title">GeoNetwork|<xsl:value-of select="//site/organization"/>|<xsl:value-of select="//site/name"/></xsl:attribute>

		</link>

		
		<!-- meta tags -->
		<xsl:copy-of select="/root/gui/strings/header_meta/meta"/>
		
		<META HTTP-EQUIV="Pragma"  CONTENT="no-cache"/>
		<META HTTP-EQUIV="Expires" CONTENT="-1"/>

		<!-- javascript -->
		<script type="text/javascript" src="{/root/gui/url}/scripts/prototype.js"/>
		<script type="text/javascript" src="{/root/gui/url}/scripts/geonetwork.js"/>
		<script type="text/javascript" src="{/root/gui/url}/scripts/form_check.js"/>
		<script type="text/javascript" src="{/root/gui/url}/scripts/HTTPRequest.js"/>
		<script type="text/javascript" src="{/root/gui/url}/FusionCharts/FusionCharts.js"/>
	
		<script language="JavaScript" type="text/javascript">
			function updateOrganizationInfo( idElement, selectedOrganizationInfo ) { 
				var informationArray = selectedOrganizationInfo.split("|");
				document.getElementById('_'+idElement).value = informationArray[1]; 
				sendUrl('<xsl:value-of select="/root/gui/locService"/>/branch.select.list?id_organization='+ informationArray[0] +'&amp;id_element='+idElement,'branches_content_'+idElement);
				
			} 
			function updateCategoryList( idElement, idContainer, selectedCategoryInfo ) { 
				var urlService = '<xsl:value-of select="/root/gui/locService"/>/category.select.list?parentId='+ selectedCategoryInfo +'&amp;id_element='+idElement;
				sendUrl( urlService, idContainer );
			}			
			function sendForm( elemForm ){
				var ht = HTTPRequest.submit ( elemForm, 
					{
						'url' : elemForm.action,
						'onSuccess' : function ( request )	{
							document.location.href = document.location;
						},
						'onError' : function ( obj )	{
							alert("Error en el servidor." + obj );
						}
					}
				);
			}
			function sendUrl( url, idContainer ){
				if( idContainer != undefined ){
					document.getElementById( idContainer ).innerHTML = "<span>Cargando...</span>";
				}
				var ht = HTTPRequest.get (
					{
						'url' : url,
						'cache' : false,
						'onSuccess' : function ( request )	{
								if(  idContainer == undefined ){
									document.location.href = document.location;
								}else{
										document.getElementById( idContainer ).innerHTML = request.responseText;
								}	
							},
						'onError' : function ( obj ) {								
							alert("Error en el servidor." + obj );
						}
					}
				);
			}
			var Env = new Object();

			Env.locService= "<xsl:value-of select="/root/gui/locService"/>";
			Env.locUrl    = "<xsl:value-of select="/root/gui/locUrl"/>";
			Env.url       = "<xsl:value-of select="/root/gui/url"/>";
			Env.lang      = "<xsl:value-of select="/root/gui/language"/>";
			
			<xsl:if test="//service/@name = 'main.home'">
            document.onkeyup = alertkey;
            
            function alertkey(e) {
             if (!e) {
                 if (window.event) {
                     e = window.event;
                 } else {
                     return;
                 }
             }
             
             if (e.keyCode == 13) {
                  <xsl:if test="string(/root/gui/session/userId)=''">
                  if ($('username').value != '') { // login action
                    goSubmit('login')
                    return;
                  }
                  </xsl:if>
                  if (document.cookie.indexOf("search=advanced")!=-1)
                    runAdvancedSearch();
                  else
                    runSimpleSearch();
             }
            };
            </xsl:if>
		</script>

	</xsl:template>
	
</xsl:stylesheet>
